Constructs an exception
Syntax
Visual Basic (Declaration) | |
---|
Public Function New( _
ByVal text As String, _
ByVal ParamArray format() As Object _
) |
Parameters
- text
- format
Example
Library/Library.Test/TestCmdInterpreter.cs
C# | Copy Code |
---|
InterpreterException ex = null;
try { throw new InterpreterException("TEST"); }
catch (InterpreterException e) { ex = e; }
Assert.IsNotNull(ex);
BinaryFormatter bf = new BinaryFormatter();
using( MemoryStream ms = new MemoryStream() )
{
bf.Serialize(ms, ex);
ms.Position = 0;
ex = (InterpreterException)bf.Deserialize(ms);
Assert.AreEqual("TEST", ex.Message);
} |
VB.NET | Copy Code |
---|
Dim ex As InterpreterException = Nothing
Try
Throw New InterpreterException("TEST")
Catch e As InterpreterException
ex = e
End Try
Assert.IsNotNull(ex)
Dim bf As New BinaryFormatter()
Using ms As New MemoryStream()
bf.Serialize(ms, ex)
ms.Position = 0
ex = DirectCast(bf.Deserialize(ms), InterpreterException)
Assert.AreEqual("TEST", ex.Message)
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also